package com.example.weather.entity;

import lombok.Data;

import java.io.Serializable;

@Data
public class Result<T> implements Serializable {
    private static final long serialVersionUID = 1L;
    int code;
    String message;
    T data;

    public Result() {
    }

    public Result(int code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }
    public Result<T> ok(T date){
        return new Result<>(200,"success",data);
    }

    public static Result ok(){
        return new Result<>(200,"success",null);
    }

    public static Result fail(){
        return new Result<>(400,"fail",null);
    }

    public Result<T> fail(T date){
        return new Result<>(400,"false",data);
    }
}
